#1 测试pandas和numpy
#复数类型的numpy
import numpy as np
import pandas as pd
a=np.array([1,2,3],dtype=complex)
#print(a)
#最小维度ndmin
li=list(range(200))

ar=np.asarray(li).reshape(50,4)
#print(ar)
df=pd.DataFrame(ar,columns=['1','2','3','4'],\
	dtype='int8')
df.to_csv('li.csv')
df1=pd.read_csv(r'li.csv')
#print(df1.head())
#打印前六行，6不写
#print(df.head(6))
#print(df.tail(5))
#print(df.info())

a=np.array([1,2,3],ndmin=2)
#print(a)
#int8,int16,int32,int64
#int8, 占1个字节.-128~127，200溢出，变成负数显示
#int16, 占2个字节.-32768~32767
#int32, 占4个字节. -2^N/2～2^N/2
#int64, 占8个字节.
b=pd.Series([1,2,3],name='123')
#print(b)

#2 测试正则表达式
import re
reg=re.compile('\w')#用于匹配字母，数字或下划线字符
#reg=re.compile('.')#表示所有字符的集
#reg=re.compile('?')
reg=re.compile("[a-z]+")
reg=re.compile('\w+')#匹配连续字母或数字或_
result=reg.findall('11the 122(｡･ω･｡)ﾉ♡ ma4n is this man')
#print(result)

#3 测试requests
#1 导入模块
import requests

#发送请求，获取响应
response=requests.get('http://www.baidu.com')
#print(response.encoding) #ISO-8859-1
#print(response.text) #打印没有中文，需要改编码
response.encoding='utf-8'
#print(response.text)#可能有乱码
#print(response.content)#获取未解码的二进制数据
#print(response.content.decode(encoding='utf-8'))#默认按utf-8解码
#print(response.content.decode())
html=response.content.decode()
#print(html)
#4 测试bs4

from bs4 import BeautifulSoup
soup=BeautifulSoup('<html>data</html>','html5lib')
#创建BeautifulSoup对象
soup=BeautifulSoup(html,'html5lib')
#print(soup)
#查找第一个title标签
title=soup.find('title')
#print(title)
#查找第一个a标签
a=soup.find('a')
#print(a)
#查找所有a标签
a_s=soup.find_all('a')
#print(a_s)
#通过属性值查找标签
a_id=soup.find(id='wrapper')
#print(a_id)
#属性不能作为命名参数时用attrs,指定字典查找

tn=soup.find(attrs={'name':'tn'})
#print(tn)
text=soup.find(text='新闻')
#print(text)
cp=soup.find(attrs={'class':'cp-feedback'})
#print(cp)
response=requests.get('https://ncov.dxy.cn/ncovh5/view/pneumonia')
home_page=response.content.decode()
print(home_page)
#soup=BeautifulSoup(home_page,'html5lib')
#print(soup)
#script =soup.find(id='')
#text=script.text
#使用正则匹配



